<?php
$link = mysql_connect('localhost','cs4350','!@'); 
if (!$link) { 
    die('Could not connect to MySQL: ' . mysql_error()); 
}
else {
    echo 'You are connected to the cs4350 database server!</br>';
}
if (!mysql_select_db( 'todo', $link)) {
    die('Aw snap, no database named todo...');
}
else {
    echo 'You are now using the todo database!</br>';
}

$username = $_POST['username'];
$count = count($_POST['deleteMe']);

//die($count);

if ($count == NULL){
	header('location:delete.php?user='.$username);
}

for($i=0; $i<$count; $i++)
{
	$sql = 'DELETE FROM list WHERE taskID="' . $_POST['deleteMe'][$i] . '"';
	$removed = mysql_query($sql, $link);
	if($removed){
		header('location:delete.php?user='.$username);
	} else {
		die($sql);
	}	
}

mysql_close($link);
?>